// pages/edit/edit.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    'lw': '',
    'jk': '',
    'xw': '',
    'yw': '',
    'xc': '',
    'yc': '',
    'bw': '',
    'kc': '',
    'dc': '',
    'dtw': '',
    'xtw': '',
    'xfyc': '',
    'xfxw': '',
    'xfjk': '',
    'xfxc': '',
    'xkc': '',
    'xkyw': '',
    'xktw': '',
    'cy': '',
  },
  //修改尺码
  smit() {
    var type = this.data.type
    console.log(this.data.type,'判断type')
    switch (type) {
      case '1':
        var list = {
          lw: this.data.lw,
          jk: this.data.jk,
          xw: this.data.xw,
          yw: this.data.yw,
          xc: this.data.xc,
          yc: this.data.yc,
          type: 1,
        }
        wx.setStorageSync('updatalist', list)
        wx.navigateBack({
          data: 1
        })
        break;
      case '2':
        var list = {
          bw: this.data.bw,
          kc: this.data.kc,
          dc: this.data.dc,
          dtw: this.data.dtw,
          xtw: this.data.xtw,
          type: 2,
        }
        wx.setStorageSync('updatalist', list)
        wx.navigateBack({
          data: 1
        })
        break;
      case '3':
        var list = {
          xfyc: this.data.xfyc,
          xfxw: this.data.xfxw,
          xfjk: this.data.xfjk,
          xfxc: this.data.xfxc,
          type: 3,
        }
        wx.setStorageSync('updatalist', list)
        wx.navigateBack({
          data: 1
        })
        break;
      case '4':
        var list = {
          xkc: this.data.xkc,
          xkyw: this.data.xkyw,
          xktw: this.data.xktw,
          type: 4,
        }
        wx.setStorageSync('updatalist', list)
        wx.navigateBack({
          data: 1
        })
        break;
      case '5':
        var list = {
          cy: this.data.cy,
          type: 5,
        }
        wx.setStorageSync('updatalist', list)
        wx.navigateBack({
          data: 1
        })
        break;
      default:
        console.log('判断出错')
    }
    console.log(list, '返回')

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      type: options.type,
    })
    const pages = getCurrentPages();
    const previousPage = pages[pages.length - 2];
    if (previousPage) {
      // 访问上一个页面的data数据
      const dataFromPreviousPage = previousPage.data;
      this.setData({
        'lw': dataFromPreviousPage.list['领围'],
        'jk': dataFromPreviousPage.list['肩宽'],
        'xw': dataFromPreviousPage.list['净胸围'],
        'yw': dataFromPreviousPage.list['腰围'],
        'xc': dataFromPreviousPage.list['袖长'],
        'yc': dataFromPreviousPage.list['衣长'],
        'bw': dataFromPreviousPage.list['净臀围'],
        'kc': dataFromPreviousPage.list['裤长'],
        'dc': dataFromPreviousPage.list['裆长'],
        'dtw': dataFromPreviousPage.list['大腿围'],
        'xtw': dataFromPreviousPage.list['小腿围'],
        'xfyc': dataFromPreviousPage.list['西装衣长'],
        'xfxw': dataFromPreviousPage.list['西装胸围'],
        'xfjk': dataFromPreviousPage.list['西装肩宽'],
        'xfxc': dataFromPreviousPage.list['西装袖长'],
        'xkc': dataFromPreviousPage.list['西裤长'],
        'xkyw': dataFromPreviousPage.list['西裤腰围'],
        'xktw': dataFromPreviousPage.list['西裤臀围'],
        'cy': dataFromPreviousPage.list['衬衣'],
      })
    }
    switch (options.type) {
      case '1':
        wx.setNavigationBarTitle({
          title: '上身尺码',
        })
        break;
      case '2':
        wx.setNavigationBarTitle({
          title: '下身尺码',
        })
        break;
      case '3':
        wx.setNavigationBarTitle({
          title: '西服上装尺码',
        })
        break;
      case '4':
        wx.setNavigationBarTitle({
          title: '西服下装尺码',
        })
        break;
      case '5':
        wx.setNavigationBarTitle({
          title: '衬衣尺码',
        })
        break;
      default:
        wx.setNavigationBarTitle({
          title: '修改尺码',
        })
        break;
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})